package com.itheima.jobs;


import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.service.OrderSettingService;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @PackageName: com.itheima.jobs
 * @ClassName: ClearOrderSettingJop
 * @Author: LiuJunMeng
 * @Date: 2020/2/16 19:27
 * @Description: //TODO
 */
public class ClearOrderSettingJop {
    @Reference
    private OrderSettingService orderSettingService;

    public void clearOrderSetting() {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date();
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.MONTH, -1);
        date = calendar.getTime();
        //获取上一个月份这一天时间
        String time = df.format(date);
        //删除上个月之前的数据
        orderSettingService.clearOrderSetting(time);
        System.out.println("任务执行了");
    }
}
